package com.example.tilitili.controller;

import com.example.tilitili.service.IUserService;
import com.example.tilitili.vo.RegisterVo;
import com.example.tilitili.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Controller
@RequestMapping("/register")
@Slf4j
public class RegisterController {

    @Autowired
    private IUserService userService;
    /*
     *跳转注册界面
     */
    @RequestMapping("/toregister")
    public String toregister(){
        return "register";
    }
    /*
     *注册功能
     */
    @RequestMapping("/doregister")
    @ResponseBody
    public RespBean doregister(@Valid RegisterVo registerVo, HttpServletRequest request, HttpServletResponse response){
        //log.info("{}",registerVo);
        //return null;
        return userService.doregister(registerVo,request,response);
    }
}
